package pro.softzhang.algo.lc100;

import pro.softzhang.algo.common.TreeNode;

import java.util.HashMap;
import java.util.Map;

/**
 *
 */
public class LC105_ConstructBinaryTreeFromPreorderAndInorderTraversal {
    public static void main(String[] args) {

    }

    static
    class Solution {
        private Map<Integer, Integer> idxMap = new HashMap<>();
        public TreeNode buildTree(int[] preorder, int[] inorder) {
            int n = inorder.length;
            for (int i = 0; i < n; i++) {
                idxMap.put(inorder[i], i);
            }
            return doBuildTree(preorder, inorder, 0, n - 1, 0, n - 1);
        }

        private TreeNode doBuildTree(int[] preorder, int[] inorder, int preorderLeft, int preorderRight, int inorderLeft, int inorderRight) {
            if (preorderLeft > preorderRight) return null;
            int preorderRoot = 0;
            int inorderRoot = idxMap.get(preorder[preorderLeft]);
            TreeNode root = new TreeNode(preorder[preorderLeft]);
            return null;
        }
    }
}
